﻿using AutoMapper;
using MediatR;
using T_vehicle.API.Application.Command.AccidentCommand;
using T_vehicle.API.Application.Command.TiresUsedCommand;
using T_vehicle.Domain;
using T_vehicle.Infrastructure.Interfacec;

namespace T_vehicle.API.Application.CommandHandlers.TiresUsedCommandHandlers
{
    public class UpdateTiresUsedCommandHandlers : IRequestHandler<UpdateTiresUsedCommand, int>
    {
        private readonly ITiresUsedRepository tiresUsedRepository;
        private readonly IMapper mapper;

        public UpdateTiresUsedCommandHandlers(ITiresUsedRepository tiresUsedRepository, IMapper mapper)
        {
            this.tiresUsedRepository = tiresUsedRepository;
            this.mapper = mapper;
        }

        public async Task<int> Handle(UpdateTiresUsedCommand request, CancellationToken cancellationToken)
        {
            var Info = mapper.Map<TiresUsed>(request);
            return await tiresUsedRepository.UpdateAsync(Info);

            //var Info = new TiresUsed();
            //Info.LicenNumber = request.LicenNumber;
            //Info.Tyre = request.Tyre;
            //Info.Specification = request.Specification;
            //Info.Quantity = request.Quantity;
            //Info.Users = request.Users;
            //Info.UsersDate = request.UsersDate;
            //Info.Remarks = request.Remarks;
            //Info.TiresUsedId = request.TiresUsedId;
            //return await tiresUsedRepository.UpdateAsync(Info);
        }
    }
}
